﻿// HSS.Forms.ConnectionProperties.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       ConnectionProperties.cs
// Author:     HSS\gbanta
// Created:    12/24/2010
// Modified:   12/24/2010
// ----------------------------------------------------------------------------
namespace HSS.Forms
{
	#region Using Directives
	using System.Data.SqlClient;
	using System.Windows.Forms;
	#endregion

	#region ConnectionProperties
	/// <summary>
	/// Provides the user with a PropertyGrid allowing complete
	/// editing of a SqlConnection String.
	/// </summary>
	public partial class ConnectionProperties : Form
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public ConnectionProperties()
		{
			InitializeComponent();
		}
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the sql connection to edit.
		/// </summary>
		public string ConnectionString
		{
			get
			{
				var dbConn = this.propertyGrid1.SelectedObject as SqlConnectionStringBuilder;
				if (null == dbConn)
					return new SqlConnectionStringBuilder().ConnectionString;
				return dbConn.ConnectionString;
			}
			set
			{
				this.propertyGrid1.SelectedObject = new SqlConnectionStringBuilder(value);
			}
		}
		#endregion

		#region Event Handlers
		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		#endregion
	}
	#endregion
}